home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1376.dms / var1376.adf / MATHSADV / TMA.C < prev    next >
C/C++ Source or Header  |  1991-03-02  |  26KB  |  1,327 lines

  1.  
  2. #include <intuition/intuition.h>
  3. #include <graphics/sprite.h>
  4. #include "crc"
  5. #include "includesound.h"
  6.  
  7. #define HEIGHT 200
  8. #define WIDTH 640
  9. #define DEPTH 4
  10.  
  11. extern struct Image title;
  12. extern struct Image ask;
  13. extern struct Image rooms;
  14. extern struct Image question;
  15.  
  16. extern struct Image square1;
  17. extern struct Image square2;
  18. extern struct Image square3;
  19.  
  20. extern struct Image start;
  21.  
  22. extern char Room1[34][70];
  23. extern char Room5[21][70];
  24. extern char Room6[40][57];
  25. extern char Room2[24][72];
  26. extern char Room3[22][70];
  27. extern char Room7[26][70];
  28. extern char Room4[26][70];
  29. extern char Room8[34][70];
  30. extern char Room9[35][70];
  31.  
  32. extern char LASTROOM[21][100];
  33. extern char LastROOM[5][100];
  34.  
  35. extern struct SoundInfo lefty;
  36. extern struct SoundInfo bad;
  37. extern struct SoundInfo good;
  38.  
  39. extern struct Image tri1;
  40. extern struct Image tri2;
  41. extern struct Image tri3;
  42.  
  43. struct Window *win;
  44. struct Screen *scr;
  45. struct IntuitionBase *IntuitionBase;
  46. struct GfxBase *GfxBase;
  47. struct ViewPort *vp;
  48. struct RastPort *rp;
  49. struct IntuiMessage *message;
  50.  
  51. USHORT class;
  52. USHORT code;
  53.  
  54. struct NewScreen ns =
  55. { 0,0,WIDTH,HEIGHT,4,0,1,HIRES,  /* View modes */
  56.   CUSTOMSCREEN,  /* Screen type */
  57.   NULL,          /* Font */
  58.   NULL,NULL,NULL          /* CustomBitmap */  };
  59.  
  60. struct NewWindow nw =
  61. { 0,0,WIDTH,HEIGHT,0,1,MOUSEBUTTONS+RAWKEY,  /* IDCMP flags */
  62.   ACTIVATE|BORDERLESS|RMBTRAP, /* Flags */
  63.   NULL,NULL,NULL,  /* Gadget,Checkmark,Name */
  64.   NULL,NULL,  /* Screen,BitMap */
  65.   WIDTH,HEIGHT,100,100,  /* Max Width,Height, Min Width,Height */
  66.   CUSTOMSCREEN  };
  67.  
  68. char children[7][10]={"KIM","ROSEMARIE","ROBERT","SANDRA","SIMON","TERRY","MELINDA" };
  69.  
  70. char r1[100],r2[100],r3[100],r4[100],users_input[20],correct_answer[20];
  71. char r5[100],r6[100];
  72. int d,e;
  73.  
  74. UWORD DUMMY_SPRITE_DATA[]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 };
  75.  
  76. main(int argc, char *argv[])
  77. {
  78. int input=1;
  79.  
  80. Open_Stuff();
  81. GetSprite(&cross,2);
  82. SetPointer(win,DUMMY_SPRITE_DATA,1,1,0,0);
  83.  
  84. InitScreenI();
  85. DrawImage(rp,&start,51,51);
  86.  
  87. Delay(25);
  88.  
  89. StopSound(RIGHT1);
  90. PlaySound(&lefty,MAXVOLUME,RIGHT1,NORMALRATE,1,0,0);
  91.  
  92. while(input)
  93.       {
  94.       while((d=idcmpch())==0);
  95.       if(d==-1) input=0; 
  96.       }
  97.  
  98. SetAPen(rp,0);
  99. RectFill(rp,1,38,638,198);
  100.  
  101. InitScreenII();
  102.  
  103. while(1)
  104.    {
  105.    DrawImage(rp,&ask,100,92);
  106.    while((input=idcmpch())==0);
  107.    if(input==0x19) { MathsAdventure(); ClearAll(); }
  108.       else if(input==0x10) die("");
  109.    ClearBORDER();
  110.    MoveBorder(1);
  111.    }
  112.  
  113.  
  114. die("");
  115.  
  116. }
  117.  
  118. DisplayEnd(){}
  119.  
  120. ClearBORDER()
  121. {
  122. ChangeSprite(vp,&cross,dummy_data);
  123. }
  124.  
  125. RenewBORDER()
  126. {
  127. ChangeSprite(vp,&cross,sprite_data);
  128. }
  129.  
  130.  
  131. /***************************************************************************/
  132. /***************************************************************************/
  133.  
  134. MathsAdventure()
  135. {
  136. int room=1,result;
  137.  
  138.  
  139. ClearAll();
  140. MoveBorder(room);
  141. RenewBORDER();
  142. MoveBorder(room);
  143. result=EnterRoom(room);
  144. if(!result) { DisplayEnd();  return(0); }
  145.  
  146. while(1)
  147.    {
  148.    ClearAll();
  149.    room=GetRoom(room);
  150.    MoveBorder(room);
  151.    result=EnterRoom(room);
  152.    if(!result) { DisplayEnd(); return(0); }
  153.    }
  154. }
  155.  
  156. /***************************************************************************/
  157. /***************************************************************************/
  158.  
  159. RETURN()
  160. {
  161. int i;
  162.  
  163. SetAPen(rp,3);
  164. WRITEIN("[RETURN]",385,170);
  165.  
  166. while(1)
  167.    {
  168.    while((i=idcmpch())==0);
  169.    if(i==0x44||i==0x43) return(0);
  170.    }
  171. }
  172.  
  173. /***************************************************************************/
  174. /***************************************************************************/
  175.  
  176. EnterRoom1()
  177. {
  178. int x,q;
  179. char buf1[60],answer[10],input[15];
  180. q=rand()%3+1;
  181.  
  182. if(q==1)
  183.    {
  184.    strcpy(buf1,"product of 9 and 12.");
  185.    strcpy(answer,"");
  186.    }
  187. else if(q==2)
  188.    {
  189.    strcpy(buf1,"sum of 14,15 and 16.");
  190.    strcpy(answer,"");
  191.    }
  192. else 
  193.    {
  194.    strcpy(buf1,"difference between 99 and 1001.");
  195.    strcpy(answer,"");
  196.    }
  197.  
  198. ClearBox1();
  199. SetAPen(rp,8);
  200. for(x=0;x<8;x++)
  201. WRITEIN(Room1[x],14,100+(10*x));
  202.  
  203. RETURN();
  204.  
  205. ClearBox1();
  206. SetAPen(rp,8);
  207. for(x=8;x<15;x++)
  208. WRITEIN(Room1[x],14,100+(10*(x-8)));
  209.  
  210. RETURN();
  211.  
  212. ClearBox1();
  213. SetAPen(rp,8);
  214. for(x=15;x<22;x++)
  215. WRITEIN(Room1[x],14,100+(10*(x-15)));
  216. WRITEIN(buf1,14,170);
  217.  
  218. GetAnswer(input);
  219. ClearBox1();
  220. SetAPen(rp,8);
  221. if(strcmp(input,answer)==0) 
  222.    {
  223.    IsCorrect(1);
  224.    for(x=22;x<26;x++)
  225.    WRITEIN(Room1[x],14,120+(10*(x-22)));
  226.    RETURN();
  227.    return(1);
  228.    }
  229.    else
  230.    {
  231.    IsCorrect(0);
  232.    for(x=26;x<34;x++)
  233.    WRITEIN(Room1[x],14,100+(10*(x-26)));
  234.    RETURN();
  235.    return(0);
  236.    }
  237. }
  238.  
  239. /***************************************************************************/
  240. /***************************************************************************/
  241.  
  242.  
  243. EnterRoom2()
  244. {
  245.  
  246. ClearAll();
  247.  
  248. strcpy(r2,"have? '");
  249.  
  250. d=rand()%3+1;
  251.  
  252. if(d==1)
  253.    {
  254.    strcpy(r1,"problem goes like this, how many sides does a pentagon");
  255.    strcpy(correct_answer,"");
  256.    }
  257. else if(d==2)
  258.    {
  259.    strcpy(r1,"problem goes like this, how many sides does a  hexagon");
  260.    strcpy(correct_answer,"");
  261.    }
  262. else
  263.    {
  264.    strcpy(r1,"problem goes like this, how many edges does a cube ");
  265.    strcpy(correct_answer,"");
  266.    }
  267.  
  268. SetAPen(rp,8);
  269. for(d=0;d<7;d++)
  270.    WRITEIN(Room2[d],14,100+(d*10));
  271. RETURN();
  272.  
  273. ClearBox1();
  274. SetAPen(rp,8);
  275. for(d=7;d<12;d++)
  276.    WRITEIN(Room2[d],14,((d-7)*10)+105);
  277. WRITEIN(r1,14,155);
  278. WRITEIN(r2,14,165); 
  279.  
  280. GetAnswer(users_input);
  281. if(strcmp(users_input,correct_answer)==0)
  282.    {
  283.    ClearBox1();
  284.    IsCorrect(1);
  285.    for(d=12;d<16;d++)
  286.       WRITEIN(Room2[d],14,((d-11)*10)+115);
  287.    RETURN();
  288.    return(1);
  289.    }
  290.    else
  291.    {
  292.    ClearBox1();
  293.    IsCorrect(0);
  294.    for(d=17;d<24;d++)
  295.       WRITEIN(Room2[d],14,((d-17)*10)+100);
  296.    RETURN();
  297.    return(0);
  298.    }
  299.  
  300. }
  301.  
  302. /*************************************************************************/
  303. /*************************************************************************/
  304. /*************************************************************************/
  305. /*************************************************************************/
  306.  
  307. EnterRoom3()
  308. {
  309.  
  310. ClearAll();
  311.  
  312. d=rand()%3+1;
  313.  
  314. if(d==1)
  315.    {
  316.    strcpy(r1,"between the hands of a clock at 3:00pm ?'");
  317.    strcpy(correct_answer,"");
  318.    }
  319. else if(d==2)
  320.    {
  321.    strcpy(r1,"between the hands of a clock at 7:00pm ?'");
  322.    strcpy(correct_answer,"");
  323.    }
  324. else
  325.    {
  326.    strcpy(r1,"between the hands of a clock at 8:00pm ?'");
  327.    strcpy(correct_answer,"");
  328.    }
  329.  
  330. SetAPen(rp,8);
  331. for(d=0;d<8;d++)
  332.    WRITEIN(Room3[d],14,100+(d*10));
  333. RETURN();
  334.  
  335. ClearBox1();
  336. SetAPen(rp,8);
  337. for(d=8;d<13;d++)
  338.    WRITEIN(Room3[d],14,((d-7)*10)+105);
  339. WRITEIN(r1,14,165);
  340.  
  341. GetAnswer(users_input);
  342. if(strcmp(users_input,correct_answer)==0)
  343.    {
  344.    ClearBox1();
  345.    IsCorrect(1);
  346.    for(d=13;d<17;d++)
  347.       WRITEIN(Room3[d],14,((d-12)*10)+115);
  348.    RETURN();
  349.    return(1);
  350.    }
  351.    else
  352.    {
  353.    ClearBox1();
  354.    IsCorrect(0);
  355.    for(d=17;d<22;d++)
  356.       WRITEIN(Room3[d],14,((d-16)*10)+115);
  357.    RETURN();
  358.    return(0);
  359.    }
  360.  
  361. }
  362.  
  363. /***************************************************************************/
  364. /***************************************************************************/
  365.  
  366.  
  367. EnterRoom4()
  368. {
  369.  
  370. ClearAll();
  371.  
  372. d=rand()%3+1;
  373.  
  374. if(d==1)
  375.    strcpy(correct_answer,"");
  376. else if(d==2)
  377.    strcpy(correct_answer,"");
  378. else
  379.    strcpy(correct_answer,"");
  380.  
  381. e=d;
  382.  
  383. SetAPen(rp,8);
  384. for(d=0;d<8;d++)
  385.    WRITEIN(Room4[d],14,100+(d*10));
  386. RETURN();
  387.  
  388. ClearBox1();
  389. SetAPen(rp,8);
  390. for(d=8;d<11;d++)
  391.    WRITEIN(Room4[d],14,((d-8)*10)+140);
  392.  
  393. if(e==1)
  394.    DrawImage(rp,&square1,205,95);
  395. else if(e==2)
  396.    DrawImage(rp,&square2,203,95);
  397. else DrawImage(rp,&square3,181,95);
  398.  
  399. GetAnswer(users_input);
  400. if(strcmp(users_input,correct_answer)==0)
  401.    {
  402.    ClearBox1();
  403.    IsCorrect(1);
  404.    for(d=11;d<19;d++)
  405.       WRITEIN(Room4[d],14,((d-11)*10)+100);
  406.    RETURN();
  407.    return(1);
  408.    }
  409.    else
  410.    {
  411.    ClearBox1();
  412.    IsCorrect(0);
  413.    for(d=19;d<26;d++)
  414.       WRITEIN(Room4[d],14,((d-19)*10)+100);
  415.    RETURN();
  416.    return(0);
  417.    }
  418.  
  419. }
  420.  
  421.  
  422. /***************************************************************************/
  423. /***************************************************************************/
  424.  
  425. EnterRoom5()
  426. {
  427.  
  428. ClearAll();
  429.  
  430. d=rand()%3+1;
  431.  
  432. if(d==1)
  433.    {
  434.    strcpy(r1,"deal with this room. Ok. I'm thinking  of a  number. If");
  435.    strcpy(r2,"you  double  it, add 5, subtract 6, divide  by  5  then");
  436.    strcpy(r3,"finally add the number I'm thinking of, you'll get  18.");
  437.    strcpy(r4,"What number am I thinking of ?'");
  438.    strcpy(correct_answer,"");
  439.    }
  440. else if(d==2)
  441.    {
  442.    strcpy(r1,"deal with this room. Ok. I'm thinking  of two  numbers."); 
  443.    strcpy(r2,"Their sum is 28 more than their difference. What is the");
  444.    strcpy(r3,"smaller number?'");
  445.    strcpy(r4,"");
  446.    strcpy(correct_answer,"");
  447.    }
  448. else
  449.    {
  450.    strcpy(r1,"deal with this room. Ok. I'm thinking of  two  numbers.");
  451.    strcpy(r2,"Their average  is 40 greater than  the  smallest number");
  452.    strcpy(r3,"and their sum is 280. What is the larger number?'");
  453.    strcpy(r4,"");
  454.    strcpy(correct_answer,"");
  455.    }
  456.  
  457. SetAPen(rp,8);
  458. for(d=0;d<8;d++)
  459.    WRITEIN(Room5[d],14,100+(d*10));
  460. RETURN();
  461.  
  462. ClearBox1();
  463. SetAPen(rp,8);
  464. for(d=8;d<10;d++)
  465.    WRITEIN(Room5[d],14,((d-8)*10)+105);
  466. WRITEIN(r1,14,125); 
  467. WRITEIN(r2,14,135); 
  468. WRITEIN(r3,14,145); 
  469. WRITEIN(r4,14,155); 
  470.  
  471. GetAnswer(users_input);
  472. if(strcmp(users_input,correct_answer)==0)
  473.    {
  474.    ClearBox1();
  475.    IsCorrect(1);
  476.    for(d=15;d<21;d++)
  477.       WRITEIN(Room5[d],14,((d-16)*10)+115);
  478.    RETURN();
  479.    return(1);
  480.    }
  481.    else
  482.    {
  483.    ClearBox1();
  484.    IsCorrect(0);
  485.    for(d=10;d<15;d++)
  486.       WRITEIN(Room5[d],14,((d-10)*10)+110);
  487.    RETURN();
  488.    return(0);
  489.    }
  490.  
  491. }
  492.  
  493.  
  494. /***************************************************************************/
  495. /***************************************************************************/
  496.  
  497. EnterRoom6()
  498. {
  499.  
  500. d=rand()%3+1;
  501. if(d==1)
  502.    {
  503.    strcpy(r1,"    At a party 66 handshakes were exchanged. If each");
  504.    strcpy(r2,"person shook hands with each other exactly once, how");
  505.    strcpy(r3,"many people were present at the party?");
  506.    strcpy(correct_answer,"");
  507.    }
  508.    else if(d==2)
  509.    {
  510.    strcpy(r1,"    How many solid cubes of side length 2cm can be made"); 
  511.    strcpy(r2,"from a solid block of wood measuring 4cm by 8cm by 2cm?");
  512.    strcpy(r3,"");
  513.    strcpy(correct_answer,"");
  514.    }
  515.    else 
  516.    {
  517.    strcpy(r1,"   A cube of  side length 8cm is  made up of individual");
  518.    strcpy(r2,"1cm cubes. How many of these 1cm cubes are face-to-face");
  519.    strcpy(r3,"with exactly four other 1cm cubes?");
  520.    strcpy(correct_answer,"");
  521.    }
  522.  
  523. for(d=0;d<3;d++)
  524.    {
  525.    ClearBox1();
  526.    SetAPen(rp,8);
  527.    for(e=d*8;e<(d*8+8);e++)
  528.       WRITEIN(Room6[e],14,((e-(d*8))*10)+100);
  529.    RETURN();   
  530.    }
  531.  
  532. ClearBox1();
  533. SetAPen(rp,8);
  534. WRITEIN(Room6[24],14,125);
  535. WRITEIN(r1,14,135);
  536. WRITEIN(r2,14,145);
  537. WRITEIN(r3,14,155);
  538.  
  539. GetAnswer(users_input);
  540. if(strcmp(users_input,correct_answer)==0)
  541.    {
  542.    ClearBox1();
  543.    IsCorrect(1);
  544.    for(d=25;d<33;d++)
  545.       WRITEIN(Room6[d],14,((d-25)*10)+100);
  546.    RETURN();
  547.    return(1);
  548.    }
  549.    else
  550.    {
  551.    ClearBox1();
  552.    IsCorrect(0);
  553.    for(d=33;d<40;d++)
  554.       WRITEIN(Room6[d],14,((d-33)*10)+100);
  555.    RETURN();
  556.    return(0);
  557.    }
  558.  
  559. }
  560.  
  561. /***************************************************************************/
  562. /***************************************************************************/
  563.  
  564. EnterRoom7()
  565. {
  566.  
  567. ClearAll();
  568.  
  569. d=rand()%3+1;
  570.  
  571. if(d==1)
  572.    {
  573.    strcpy(correct_answer,"");
  574.    }
  575. else if(d==2)
  576.    {
  577.    strcpy(correct_answer,"");
  578.    }
  579. else
  580.    {
  581.    strcpy(correct_answer,"");
  582.    }
  583.  
  584. e=d;
  585.  
  586. SetAPen(rp,8);
  587. for(d=0;d<8;d++)
  588.    WRITEIN(Room7[d],14,100+(d*10));
  589. RETURN();
  590.  
  591. ClearBox1();
  592.  
  593. if(e==1) DrawImage(rp,&tri1,176,95);
  594. else if(e==2) DrawImage(rp,&tri2,156,95);
  595. else DrawImage(rp,&tri3,158,95);
  596.  
  597. SetAPen(rp,8);
  598. for(d=8;d<11;d++)
  599.    WRITEIN(Room7[d],14,140+((d-8)*10));
  600.  
  601. GetAnswer(users_input);
  602. if(strcmp(users_input,correct_answer)==0)
  603.    {
  604.    ClearBox1();
  605.    IsCorrect(1);
  606.    for(d=11;d<18;d++)
  607.       WRITEIN(Room7[d],14,((d-11)*10)+100);
  608.    RETURN();
  609.    return(1);
  610.    }
  611.    else
  612.    {
  613.    ClearBox1();
  614.    IsCorrect(0);
  615.    for(d=18;d<26;d++)
  616.       WRITEIN(Room7[d],14,((d-18)*10)+100);
  617.    RETURN();
  618.    return(0);
  619.    }
  620.  
  621. }
  622.  
  623. /***************************************************************************/
  624. /***************************************************************************/
  625.  
  626. EnterRoom8()
  627. {
  628.  
  629. ClearAll();
  630.  
  631. strcpy(correct_answer,"");
  632.  
  633.  
  634. SetAPen(rp,8);
  635. for(d=0;d<8;d++)
  636.    WRITEIN(Room8[d],14,100+(d*10));
  637. RETURN();
  638.  
  639. ClearBox1();
  640. SetAPen(rp,8);
  641. for(d=8;d<14;d++)
  642.    WRITEIN(Room8[d],14,100+((d-7)*10));
  643. RETURN();
  644.  
  645. ClearBox1();
  646. SetAPen(rp,8);
  647. for(d=14;d<22;d++)
  648.    WRITEIN(Room8[d],14,100+((d-14)*10));
  649.  
  650. GetAnswer(users_input);
  651. if(strcmp(users_input,correct_answer)==0)
  652.    {
  653.    ClearBox1();
  654.    IsCorrect(1);
  655.    for(d=22;d<28;d++)
  656.       WRITEIN(Room8[d],14,((d-22)*10)+105);
  657.    RETURN();
  658.    return(1);
  659.    }
  660.    else
  661.    {
  662.    ClearBox1();
  663.    IsCorrect(0);
  664.    for(d=28;d<34;d++)
  665.       WRITEIN(Room8[d],14,((d-28)*10)+105);
  666.    RETURN();
  667.    return(0);
  668.    }
  669.  
  670. }
  671.  
  672. /***************************************************************************/
  673. /***************************************************************************/
  674.  
  675. EnterRoom9()
  676. {
  677.  
  678. ClearAll();
  679.  
  680. d=rand()%3+1;
  681.  
  682. if(d==1)
  683.    strcpy(correct_answer,"");
  684. else 
  685.    strcpy(correct_answer,"");
  686.  
  687. e=d;
  688.  
  689. SetAPen(rp,8);
  690. for(d=0;d<8;d++)
  691.    WRITEIN(Room9[d],14,100+(d*10));
  692. RETURN();
  693.  
  694. ClearBox1();
  695. SetAPen(rp,8);
  696. for(d=8;d<16;d++)
  697.    WRITEIN(Room9[d],14,((d-8)*10)+100);
  698. RETURN();
  699.  
  700. ClearBox1();
  701. SetAPen(rp,8);
  702. if(e==1)
  703.    for(d=16;d<20;d++)
  704.       WRITEIN(Room9[d],14,((d-15)*10)+100);
  705. else
  706.    for(d=20;d<27;d++)
  707.       WRITEIN(Room9[d],14,((d-19)*10)+100);
  708.  
  709. GetAnswer(users_input);
  710. if(strcmp(users_input,correct_answer)==0)
  711.    {
  712.    ClearBox1();
  713.    IsCorrect(1);
  714.    for(d=30;d<34;d++)
  715.       WRITEIN(Room9[d],14,((d-29)*10)+100);
  716.    RETURN();
  717.    return(1);
  718.    }
  719.    else
  720.    {
  721.    ClearBox1();
  722.    IsCorrect(0);
  723.    for(d=27;d<30;d++)
  724.       WRITEIN(Room9[d],14,((d-25)*10)+100);
  725.    RETURN();
  726.    return(0);
  727.    }
  728.  
  729. }
  730.  
  731. /***************************************************************************/
  732. /***************************************************************************/
  733.  
  734. LastRoom()
  735. {
  736. char buf[100];
  737. int across,dummy=1,x,dummy2=1,a[10];
  738.  
  739. ClearBORDER();
  740. MakeWay();
  741. SetAPen(rp,8);
  742.  
  743. for(x=0;x<5;x++)
  744.    WRITEIN(LastROOM[x],20,50+(10*x));
  745.  
  746. WRITEIN("JUST PRESS 'Y' or 'N' for your answer. (No need to press RETURN).",58,105);
  747.  
  748. while(dummy)
  749.    {
  750.       for(x=0;x<7;x++)
  751.       {
  752.       sprintf(buf,"Does %s catch the train?",children[x]);
  753.       across=350-(strlen(buf)*8);
  754.       SetAPen(rp,11);
  755.       WRITEIN(buf,across,120+(10*x));
  756.  
  757.       dummy2=1;
  758.       while(dummy2)
  759.          {
  760.          across=idcmpch();
  761.          if(across==0x15) { a[x]=1; strcpy(buf,"Yes"); dummy2=0; SetAPen(rp,3); }
  762.             else if(across==0x36) { a[x]=0; strcpy(buf,"No"); dummy2=0; SetAPen(rp,9);}
  763.          }
  764.       WRITEIN(buf,360,120+(10*x));
  765.       }
  766.  
  767.    SetAPen(rp,8);
  768.    WRITEIN("Is this correct??? (Y/N)",220,190);
  769.    dummy2=1;
  770.       while(dummy2)
  771.       {
  772.       across=idcmpch();
  773.       if(across==0x15) { dummy=0; dummy2=0; } 
  774.          else if(across==0x36) 
  775.             {
  776.             dummy2=0;
  777.             SetAPen(rp,0);
  778.             RectFill(rp,20,110,630,190);
  779.             }
  780.       }
  781.    }
  782.  
  783. ClearBig();
  784. if(MONKEYS LIKE BANANAS)
  785.    {
  786.    SetAPen(rp,8);
  787.    for(d=0;d<15;d++)
  788.       WRITEIN(LASTROOM[d],35,50+(10*d));
  789.  
  790.       SetAPen(rp,3);
  791.       WRITEIN("[RETURN]",500,170);
  792.       while(1)
  793.       {
  794.       while((d=idcmpch())==0);
  795.       if(d==0x44||d==0x43) { ClearBig(); InitScreenI(); InitScreenII(); return(0); }
  796.       }
  797.    }
  798.    else
  799.    {
  800.    SetAPen(rp,9);
  801.    for(d=15;d<21;d++)
  802.       WRITEIN(LASTROOM[d],20,70+(10*(d-15)));
  803.  
  804.       SetAPen(rp,3);
  805.       WRITEIN("[RETURN]",500,140);
  806.       while(1)
  807.       {
  808.       while((d=idcmpch())==0);
  809.       if(d==0x44||d==0x43) { ClearBig(); InitScreenI(); InitScreenII(); return(0); }
  810.       }
  811.    }
  812.  
  813. }
  814.  
  815. /***************************************************************************/
  816. /***************************************************************************/
  817.  
  818. InitScreenI()
  819. {
  820. int s,m;
  821.  
  822. CurrentTime(&s,&m);
  823. srand(999*s+9*m+9);
  824.  
  825. SetRGB4(vp,1,0xB,0xB,0xB);
  826. SetRGB4(vp,2,0x0,0x0,0xF);
  827. SetRGB4(vp,3,0x0,0xF,0x0);
  828. SetRGB4(vp,4,0x0,0x0,0xF);
  829. SetRGB4(vp,5,0x5,0x5,0x5);
  830. SetRGB4(vp,6,0x8,0x8,0x8);
  831. SetRGB4(vp,7,0xC,0xC,0xC);
  832. SetRGB4(vp,8,0x8,0xC,0xF);
  833. SetRGB4(vp,9,0xF,0x0,0x0);
  834. SetRGB4(vp,10,0xF,0x0,0x0);
  835. SetRGB4(vp,11,0x3,0x3,0xF);
  836.  
  837. SetRGB4(vp,21,0x0,0x0,0xF);
  838.  
  839. SetAPen(rp,0);
  840. RectFill(rp,8,40,638,195);
  841.  
  842. SetAPen(rp,2);
  843.  
  844. Move(rp,0,0);
  845. Draw(rp,639,0);
  846. Draw(rp,639,199);
  847. Draw(rp,0,199);
  848. Draw(rp,0,0);
  849.  
  850. DrawImage(rp,&title,28,1);
  851. }
  852.  
  853. InitScreenII()
  854. {
  855. SetAPen(rp,2);
  856.  
  857. Move(rp,8,90);
  858. Draw(rp,458,90);
  859. Draw(rp,458,176);
  860. Draw(rp,8,176);
  861. Draw(rp,8,90);
  862.  
  863. Move(rp,465,90);
  864. Draw(rp,631,90);
  865. Draw(rp,631,195);
  866. Draw(rp,465,195);
  867. Draw(rp,465,90);
  868.  
  869. Move(rp,8,179);
  870. Draw(rp,458,179);
  871. Draw(rp,458,195);
  872. Draw(rp,8,195);
  873. Draw(rp,8,179);
  874.  
  875. Move(rp,78,40);
  876. Draw(rp,562,40);
  877. Draw(rp,562,86);
  878. Draw(rp,78,86);
  879. Draw(rp,78,40);
  880.  
  881. DrawImage(rp,&rooms,118,44);
  882. }
  883.  
  884.  
  885.  
  886.  
  887. /*************************************************************************/
  888. /*************************************************************************/
  889. /*************************************************************************/
  890. /***************************                      ************************/
  891. /***************************    Functions....     ************************/
  892. /***************************                      ************************/
  893. /*************************************************************************/
  894. /*************************************************************************/
  895. /*************************************************************************/
  896.  
  897. int idcmpch()
  898. {
  899.         if(win->UserPort->mp_SigBit)
  900.         if(message=(struct IntuiMessage *)GetMsg(win->UserPort))
  901.         {
  902.         class=message->Class;
  903.         code=message->Code;
  904.         ReplyMsg((struct IntuiMessage *)message);
  905.            switch(class)
  906.               {
  907.               case MOUSEBUTTONS:
  908.                    switch(code)
  909.                    {
  910.                    case SELECTDOWN:
  911.                    return(-1);
  912.                    }
  913.               case RAWKEY:
  914.                    return((int)code);
  915.               }
  916.         }
  917. return(0);  /* Nothing interesting! */
  918. }
  919.  
  920.  
  921.  
  922. Open_Stuff()
  923. {
  924.  
  925. void *OpenLibrary();
  926. struct Window *OpenWindow();
  927. struct Screen *OpenScreen();
  928.  
  929. if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0)))
  930.    die("   Can't open intuition.library");
  931.  
  932. if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0)))
  933.    die("   Can't open graphics library");
  934.  
  935.  
  936. if((scr=OpenScreen(&ns))==NULL)
  937. die("   NOT ENOUGH MEMORY!!!");
  938.  
  939. nw.Screen=scr;
  940.  
  941. if(!(win=(struct Window *)OpenWindow(&nw)))
  942.    die("   NOT ENOUGH MEMORY!!!");
  943.  
  944. rp=win->RPort;
  945. vp=&scr->ViewPort;
  946.  
  947. SetRGB4(vp,0,0,0,0);
  948.  
  949. return(TRUE);
  950.  
  951. }
  952.  
  953.  
  954. die(s)
  955. char *s[];
  956. {
  957. char Alert[300];
  958. register int loop;
  959.  
  960. if(strlen(s)!=0) /* Display alert if s isn't NULL */
  961.    {
  962.    memset((void *)Alert,0,sizeof(Alert));
  963.    strcat(Alert,s);
  964.    strcat(Alert,"       Press either mouse button to continue.");
  965.    loop=strlen(s);
  966.    Alert[0]=0; Alert[1]=32; Alert[2]=16;
  967.    Alert[loop+2]='\0'; Alert[loop+3]=TRUE;
  968.    Alert[loop+4]=0; Alert[loop+5]=32; Alert[loop+6]=32;
  969.    Alert[loop+45]='\0'; Alert[loop+46]=FALSE;
  970.    DisplayAlert(RECOVERY_ALERT,Alert,48);
  971.    }
  972.  
  973. if(cross.num!=-1) FreeSprite(2); 
  974.  
  975. StopSound(RIGHT1);
  976. StopSound(LEFT0);
  977.  
  978. if(win) CloseWindow(win);
  979. if(scr) CloseScreen(scr);
  980. if(GfxBase) CloseLibrary(GfxBase);
  981. if(IntuitionBase) CloseLibrary(IntuitionBase);
  982. exit();
  983. return(TRUE);
  984. }
  985.  
  986.  
  987. GetAnswer(char answer[])
  988. {
  989. int dummy=1,maindummy=1,i=0,w=0,decimal=0,start,end;
  990. char input[20],final[20];
  991.  
  992. memset((void *)final,0,sizeof(final));
  993.  
  994. DrawImage(rp,&question,466,91);
  995.  
  996. SetAPen(rp,8);
  997. while(maindummy)
  998. {
  999. memset((void *)input,0,sizeof(input));
  1000. w=0;
  1001. decimal=0;
  1002. dummy=1;
  1003.  
  1004. Move(rp,508,179);
  1005. Text(rp,"           ",10);
  1006. Move(rp,473,190);
  1007. Text(rp,"                    ",19);
  1008.  
  1009. while(dummy)
  1010.    {
  1011.    while((i=idcmpch())==0);
  1012.       if(w<10)
  1013.       {
  1014.       if( i>=0x01  &&  i<=0x0A )
  1015.          if(i==0x0A) input[w++]='0'; else input[w++]=48+i;
  1016.       if( i>=0x1D  &&  i<=0x1F )
  1017.          input[w++]=i-0x1D+49;
  1018.       else if( i>=0x2D  &&  i<=0x2F )
  1019.          input[w++]=i-0x2D+52;
  1020.       else if( i>=0x3D  &&  i<=0x3F )
  1021.          input[w++]=i-0x3D+55;
  1022.       else if( i==0x0F ) input[w++]='0';
  1023.       } 
  1024.  
  1025.       if(!decimal)
  1026.       if( i==0x3C  ||  i==0x39)
  1027.          {
  1028.          input[w++]='.'; 
  1029.          decimal=1;
  1030.          }
  1031.       Move(rp,508,179);
  1032.       Text(rp,input,strlen(input));
  1033.  
  1034.       if(i==0x41  &&  w>0)
  1035.          {
  1036.          if(input[w-1]=='.') decimal=0;
  1037.          Move(rp,8*w+500,179);  
  1038.          Text(rp," ",1);
  1039.          input[--w]='\0';
  1040.          }
  1041.          
  1042.       if(i==0x44||i==0x43) dummy=0;
  1043.    
  1044.    }
  1045. dummy=1;
  1046. Move(rp,473,190);
  1047. Text(rp,"Are you sure? (Y/N)",19);
  1048. while(dummy)
  1049.    {
  1050.    while((i=idcmpch())==0);
  1051.    if(i==0x15) { dummy=0; maindummy=0; }
  1052.       else if(i==0x36) dummy=0;
  1053.    }
  1054. }
  1055. start=0;
  1056. while(input[start++]=='0');
  1057. if(decimal)
  1058.    {
  1059.    end=strlen(input)-1;
  1060.    if(input[end]=='0')
  1061.    while(input[end--]=='0');
  1062.    } else end=strlen(input)-1;
  1063. --start;
  1064. for(i=start,w=0;i<=end;i++,w++)
  1065.    final[w]=input[i];
  1066. if(final[strlen(final)-1]=='.') final[strlen(final)-1]='\0';
  1067.  
  1068. strcpy(answer,final);
  1069. }
  1070.  
  1071.  
  1072.  
  1073.      
  1074. GetRoom(int ro)
  1075. {
  1076. int i,dummy=1,maindummy=1,w=0,correct1,correct2;
  1077. char r[10];
  1078.  
  1079. ClearBox1();
  1080.  
  1081. if(ro==1) { correct1=2; correct2=3; }
  1082.    else if(ro==2||ro==3) { correct1=4; correct2=4; }
  1083.       else if(ro==4) { correct1=5; correct2=6; }
  1084.          else if(ro==5||ro==6) { correct1=7; correct2=7; }
  1085.             else if(ro==7) { correct1=8; correct2=8; }
  1086.                else if(ro==8) { correct1=9; correct2=9; }
  1087.                   else if(ro==9) { correct1=10; correct2=10; }
  1088.  
  1089. SetAPen(rp,8);
  1090. Move(rp,105,120);
  1091. Text(rp,"Which room shall you enter next.",32);
  1092.  
  1093. while(maindummy)
  1094. {
  1095. Move(rp,224,130); Text(rp,"        ",5);
  1096. Move(rp,145,140); Text(rp,"                          ",23);
  1097. w=0; 
  1098. memset((void *)r,0,sizeof(r));
  1099. dummy=1;
  1100.  
  1101. SetAPen(rp,9); 
  1102. while(dummy)
  1103.    {
  1104.    while((i=idcmpch())==0);
  1105.    if(w<2)
  1106.    if(i>=0x00 && i<=0x0A)
  1107.          {
  1108.          if(i==0x0A) 
  1109.             {
  1110.             if(r[0]=='1') r[w++]='0';
  1111.             }  
  1112.          else if(w==0) r[w++]=i+48;
  1113.          }
  1114.    else if(w==0)
  1115.          {
  1116.          if( i>=0x1D && i<=0x1F ) r[w++]=i-0x1E+50;
  1117.             else if(i>=0x2D&&i<=0x2F) r[w++]=i-0x2D+52;
  1118.                else if(i>=0x3D&&i<=0x3F) r[w++]=i-0x3D+55;
  1119.          }
  1120.          else if(r[0]=='1'&&i==0x0F) r[w++]='0';
  1121.  
  1122.    if(i==0x41&&w>0) 
  1123.       if(w==2) 
  1124.       {
  1125.       w=1;
  1126.       r[1]='\0';
  1127.       Move(rp,232,130); Text(rp,"  ",2);
  1128.       } 
  1129.       else
  1130.       {
  1131.       w=0;
  1132.       r[0]='\0';
  1133.       Move(rp,224,130); Text(rp,"  ",2);
  1134.       }
  1135.    
  1136.    if(i==0x44||i==0x43) if(w>0) dummy=0;
  1137.    Move(rp,224,130); Text(rp,r,strlen(r));
  1138.    }
  1139.  
  1140. SetAPen(rp,8);
  1141. Move(rp,145,140);
  1142. Text(rp,"Is this correct? (Y/N)",22);
  1143.  
  1144. dummy=1;
  1145. while(dummy)
  1146.    {
  1147.    while((i=idcmpch())==0);
  1148.    if(i==0x15) { maindummy=0; dummy=0; }
  1149.       else if(i==0x36) dummy=0;
  1150.    }
  1151.  
  1152. if(r[0]=='0') { r[0]=r[1]; r[1]='\0'; } 
  1153. dummy=atoi(r);
  1154. if(dummy!=correct1&&dummy!=correct2)
  1155.    if(maindummy==0)
  1156.       {
  1157.       Move(rp,93,150);
  1158.       Text(rp,"You can't enter that room! [RETURN]",35);
  1159.       while(1)
  1160.          {
  1161.          dummy=idcmpch();
  1162.          if(dummy==0x43||dummy==0x44) break; 
  1163.          }
  1164.       maindummy=1;
  1165.       Move(rp,93,150);
  1166.       Text(rp,"                                      ",35);
  1167.       }
  1168.  
  1169. }
  1170.  
  1171. ClearBox1();
  1172.  
  1173. return(atoi(r));     
  1174.  
  1175. }
  1176.  
  1177.  
  1178. MoveBorder(int r)
  1179. {
  1180.   if(r==2) MoveSprite(0,&cross,83,44);
  1181.    else if(r==3) MoveSprite(0,&cross,83,65);
  1182.     else if(r==4) MoveSprite(0,&cross,108,54);
  1183.      else if(r==5) MoveSprite(0,&cross,133,44);
  1184.       else if(r==6) MoveSprite(0,&cross,133,65);
  1185.        else if(r==7) MoveSprite(0,&cross,158,54);
  1186.         else if(r==8) MoveSprite(0,&cross,183,54);
  1187.          else if(r==9) MoveSprite(0,&cross,208,54);
  1188.           else if(r==10) MoveSprite(0,&cross,238,54);
  1189.            else MoveSprite(0,&cross,58,54);
  1190. }
  1191.  
  1192.  
  1193. ClearBox1()
  1194. {
  1195. SetAPen(rp,0);
  1196. RectFill(rp,9,91,457,175);
  1197. }
  1198.  
  1199. ClearBox2()
  1200. {
  1201. SetAPen(rp,0);
  1202. RectFill(rp,9,180,457,194);
  1203. }
  1204.  
  1205. ClearBox3()
  1206. {
  1207. SetAPen(rp,0);
  1208. RectFill(rp,466,91,630,194);
  1209. }
  1210.  
  1211. ClearAll()
  1212. {
  1213. ClearBox1();
  1214. ClearBox2();
  1215. ClearBox3();
  1216. }
  1217.  
  1218. WRITEIN(char s[],int x,int y)
  1219. {
  1220. Move(rp,x,y);
  1221. Text(rp,s,strlen(s));
  1222. }
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228. MakeWay()
  1229. {
  1230. SetAPen(rp,0);
  1231.  
  1232. Move(rp,0,0);
  1233. Draw(rp,639,0);
  1234. Draw(rp,639,199);
  1235. Draw(rp,0,199);
  1236. Draw(rp,0,0);
  1237.  
  1238. Move(rp,8,90);
  1239. Draw(rp,458,90);
  1240. Draw(rp,458,176);
  1241. Draw(rp,8,176);
  1242. Draw(rp,8,90);
  1243.  
  1244. Move(rp,465,90);
  1245. Draw(rp,631,90);
  1246. Draw(rp,631,195); 
  1247. Draw(rp,465,195);
  1248. Draw(rp,465,90);
  1249.  
  1250. Move(rp,8,179);
  1251. Draw(rp,458,179);
  1252. Draw(rp,458,195);
  1253. Draw(rp,8,195);
  1254. Draw(rp,8,179);
  1255.  
  1256. Move(rp,78,40);
  1257. Draw(rp,562,40);
  1258. Draw(rp,562,86);
  1259. Draw(rp,78,86);
  1260. Draw(rp,78,40);
  1261.  
  1262.  
  1263. SetAPen(rp,0);
  1264. RectFill(rp,9,41,623,145);
  1265.  
  1266. SetAPen(rp,2);
  1267. Move(rp,8,40);
  1268. Draw(rp,631,40);
  1269. Draw(rp,631,195);
  1270. Draw(rp,8,195);
  1271. Draw(rp,8,40);
  1272. }
  1273.  
  1274.  
  1275. EnterRoom(int r)
  1276. {
  1277. if(r==1) return(EnterRoom1());
  1278.    else if(r==2) return(EnterRoom2());
  1279.       else if(r==3) return(EnterRoom3());
  1280.          else if(r==4) return(EnterRoom4());
  1281.             else if(r==5) return(EnterRoom5());
  1282.                else if(r==6) return(EnterRoom6());
  1283.                   else if(r==7) return(EnterRoom7());
  1284.                      else if(r==8) return(EnterRoom8());
  1285.                         else if(r==9) return(EnterRoom9());
  1286.                            else LastRoom();
  1287. }
  1288.  
  1289. IsCorrect(int r)
  1290. {
  1291. int i=1,dummy=1;
  1292. char correct[20];
  1293.  
  1294. if(r==1) strcpy(correct,"CORRECTLY"); else strcpy(correct,"INCORRECTLY");
  1295.  
  1296. SetAPen(rp,8);
  1297. Move(rp,72,190);
  1298. Text(rp,"You answered that question",26);
  1299.  
  1300. if(r==1) SetAPen(rp,3); else SetAPen(rp,9);
  1301. Move(rp,297,190);
  1302. Delay(75);
  1303. Text(rp,correct,strlen(correct));
  1304.  
  1305. if(r==1) PlayGOOD(); else PlayBAD();
  1306. Delay(25);
  1307. }
  1308.  
  1309. ClearBig()
  1310. {
  1311. SetAPen(rp,0);
  1312. RectFill(rp,9,41,630,194);
  1313. }
  1314.  
  1315. PlayGOOD()
  1316. {
  1317. StopSound(LEFT0);
  1318. PlaySound(&good,MAXVOLUME,RIGHT1,NORMALRATE,1,0,0);
  1319. }
  1320.  
  1321. PlayBAD()
  1322. {
  1323. StopSound(LEFT0);
  1324. PlaySound(&bad,MAXVOLUME,RIGHT1,NORMALRATE,1,0,0);
  1325. }
  1326.  
  1327.